package cn.backpackerxl.service.impl;

import cn.backpackerxl.dao.TeacherDao;
import cn.backpackerxl.easyJDBC.main.EasyJDBCRepository;
import cn.backpackerxl.entity.Teacher;
import cn.backpackerxl.service.TeacherService;

import java.util.List;

/**
 * @Author: backpackerxl
 * CreateTime: 2022/5/1
 * FileName: TeacherServiceImpl
 **/
public class TeacherServiceImpl implements TeacherService {

    private final TeacherDao teacherDao = (TeacherDao) new EasyJDBCRepository(TeacherDao.class).init();

    @Override
    public int add(Teacher teacher) {
        return teacherDao.save(teacher);
    }

    @Override
    public int delete(Long id) {
        return teacherDao.remove(id);
    }

    @Override
    public int edit(Teacher teacher) {
        return teacherDao.update(teacher);
    }

    @Override
    public List<Teacher> all() {
        return teacherDao.findAll();
    }
}
